import request from '@/utils/request'

// 优惠券列表查询
export function getCouponList(params) {
  return request({
    url: '/manage/coupon/coupon/page',
    method: 'get',
    params
  })
}

// 新增优惠券
export function addCoupon(data) {
  return request({
    url: '/manage/coupon/coupon',
    method: 'post',
    data
  })
}

// 编辑优惠券
export function editCoupon(data) {
  return request({
    url: '/manage/coupon/coupon',
    method: 'put',
    data
  })
}

// 获取优惠券详情
export function getCouponDetail(id) {
  return request({
    url: '/manage/coupon/coupon/' + id,
    method: 'get',
  })
}

// 提交审核
export function submitAuditCoupon(id) {
  return request({
    url: '/manage/coupon/coupon/submit/audit/' + id,
    method: 'put',
  })
}

// 删除优惠券
export function deleteCoupon(id) {
  return request({
    url: '/manage/coupon/coupon/' + id,
    method: 'delete',
  })
}

// 审核优惠券
export function auditCoupon(data) {
  return request({
    url: '/manage/coupon/coupon/audit',
    method: 'put',
    data
  })
}

//管理员优惠券列表查询
export function getAdminCouponList(params) {
  return request({
    url: '/manage/coupon/coupon/pageByAdmin',
    method: 'get',
    params
  })
}

// 查询省和市信息接口
export function getProvinceAndCity(params) {
  return request({
    url: '/area/byCityCode',
    method: 'get',
    params: params
  })
}

// 优惠券提前结束
export function earlyFinishCoupon(id) {
  return request({
    url: '/manage/coupon/coupon/earlyFinish/'+id,
    method: 'put',
  })
}

// 优惠券管理员管理状态统计
export function getCouponCount(params) {
  return request({
    url: '/manage/coupon/coupon/countState',
    method: 'get',
    params: params
  })
}

// 指派优惠券
export function appointCoupon(data) {
  return request({
    url: '/manage/coupon/record/appoint',
    method: 'put',
    data
  })
}

